package de.upb.aquarium.api.camera;

import javax.media.opengl.GL;
import javax.media.opengl.glu.GLU;

import de.upb.aquarium.World;


public class PerspectiveProjection implements IProjection {
	
	private double aspectRatio;
	private double openAngle;
	private double farClipping;
	private double nearClipping;
	
	public PerspectiveProjection(double aspectRatio, double openAngle,
			double farClipping, double nearClipping) {
		super();
		this.aspectRatio = aspectRatio;
		this.openAngle = openAngle;
		this.farClipping = farClipping;
		this.nearClipping = nearClipping;
	}

	@Override
	public void addProjectionMatrix() {
		GL gl = World.getInstance().getGL();
		GLU glu = World.getInstance().getGLU();
		
		gl.glMatrixMode(GL.GL_PROJECTION);
		glu.gluPerspective(
				openAngle,
				aspectRatio,
				nearClipping,
				farClipping);
	}
	
	
	public double getAspectRatio() {
		return aspectRatio;
	}

	public void setAspectRatio(double aspectRatio) {
		this.aspectRatio = aspectRatio;
	}

	public double getOpenAngle() {
		return openAngle;
	}

	public void setOpenAngle(double openAngle) {
		this.openAngle = openAngle;
	}

	public double getFarClipping() {
		return farClipping;
	}

	public void setFarClipping(double farClipping) {
		this.farClipping = farClipping;
	}

	public double getNearClipping() {
		return nearClipping;
	}

	public void setNearClipping(double nearClipping) {
		this.nearClipping = nearClipping;
	}
}
